package cn.wolfcode.p2p.bussness.service.impl;

import cn.wolfcode.p2p.base.query.QueryObject;
import cn.wolfcode.p2p.bussness.domain.PaymentScheduleDetail;
import cn.wolfcode.p2p.bussness.mapper.PaymentScheduleDetailMapper;
import cn.wolfcode.p2p.bussness.service.IPaymentScheduleDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class PaymentScheduleDetailServiceImpl implements IPaymentScheduleDetailService {

    @Autowired
    private PaymentScheduleDetailMapper paymentScheduleDetailMapper;

    @Override
    public int save(PaymentScheduleDetail paymentScheduleDetail) {
        return paymentScheduleDetailMapper.insert(paymentScheduleDetail);
    }

    @Override
    public int update(PaymentScheduleDetail paymentScheduleDetail) {
        return paymentScheduleDetailMapper.updateByPrimaryKey(paymentScheduleDetail);
    }

    @Override
    public PaymentScheduleDetail get(Long id) {
        return paymentScheduleDetailMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo queryPage(QueryObject qo) {
        PageHelper.startPage(qo.getPageNum(), qo.getPageSize());
        List<PaymentScheduleDetail> list = paymentScheduleDetailMapper.selectList(qo);
        return new PageInfo(list);
    }

    @Override
    public void updatePayDate(Long paymentScheduleId, Date payDate) {
        paymentScheduleDetailMapper.updatePayDate(paymentScheduleId,payDate);
    }
}
